<?php
/**
 * 
 * Modelo de MAIL_HeaderCI
 * @author natanael
 */
class MailHeaderCi extends Model
{
      private $_nameTable = "MAIL_HeaderCI";
      
      public function __construct()
      {
          parent::Model();
          $this->load->database();
      }
      
      public function loadRegistro($start = false, $offset = false, $sortname = false, $sortorder = false)
      {
            
             if($offset != false){
                  $this->db->limit($offset, $start);
             }
				 
			 if($sortname != false && $sortorder != false){ 
				  $this->db->order_by($sortname, $sortorder);
			 }	  
				  
		     $result = $this->db->get_where($this->_nameTable);
	
		    return $this->GetArrayFromQueryResult($result);
			
      }
     
      private function GetArrayFromQueryResult($result) 
	  {
			if ($result->num_rows() == 0)
				return false;
	
			$objeto_arr = array();
	
			foreach ($result->result() as $record) {
				$objeto_arr[] = new MMailHeaderCi($record);
			}
	
			return $objeto_arr;
      }
      
      public function addRegistro($data)
      {
           if ($this->db->insert($this->_nameTable,$data)){
           	     
           	     $this->db->order_by("IdHether", "desc"); 
	             $result = $this->db->get($this->_nameTable);
	             return $this->GetArrayFromQueryResult($result);	
           	
           }
           
            return false;
       }
  
      
}

class MMailHeaderCi{

      private $_idHether;
      private $_fecha;
      private $_hora;
      private $_tipo;
      private $_cantidaMail;
      private $_usuario;
      private $_categoria;
      
      public function __construct($obj)
      {
           $this->setIdHether($obj->IdHether);
           $this->setFecha($obj->Fecha);
           $this->setHora($obj->Hora);
           $this->setTipo($obj->Tipo);
           $this->setCantidaMail($obj->CantidaMail);
           $this->setUsuario($obj->Usuario);
           $this->setCategoria($obj->Categoria);
      }
      
      public function getIdHether()
      {
          return $this->_idHether;
      }
      
      public function setIdHether($obj)
      {
          $this->_idHether = $obj;
      }
      
      public function getFecha()
      {
          return $this->_fecha;
      }
      
      public function setFecha($obj)
      {
          $this->_fecha = $obj;
      }

      public function getHora()
      {
          return $this->_hora;
      }
      
      public function setHora($obj)
      {
          $this->_hora = $obj;
      }
    
      public function getTipo()
      {
          return $this->_tipo;
      }
      
      public function setTipo($obj)
      {
          $this->_tipo = $obj;
      }
      
      public function getCantidaMail()
      {
          return $this->_cantidaMail;
      }
      
      public function setCantidaMail($obj)
      {
          $this->_cantidaMail = $obj;
      }
      
      public function getUsuario()
      {
          return $this->_usuario;
      }
      
      public function setUsuario($obj)
      {
          $this->_usuario = $obj;
      }
      
      public function getCategoria()
      {
          return $this->_categoria;
      }
      
      public function setCategoria($obj)
      {
          $this->_categoria = $obj;
      }
}